I_FROM_V

Overview

The I_FROM_V function calculates the device current at a given device voltage for a photovoltaic (PV) cell or module using the single diode model (SDM). This function is essential for modeling IV curves, which characterize how a solar cell’s output current varies with voltage under specific operating conditions.

The single diode model represents a solar cell as an equivalent circuit containing a current source (representing photogenerated current), a diode (representing recombination losses), a series resistance, and a shunt resistance. The characteristic equation relating current I to voltage V is:

I = I_L - I_0 \left[ \exp\left( \frac{V + I \cdot R_s}{n \cdot N_s \cdot V_{th}} \right) - 1 \right] - \frac{V + I \cdot R_s}{R_{sh}}

where I_L is the photocurrent, I_0 is the diode saturation current, R_s is the series resistance, R_{sh} is the shunt resistance, n is the diode ideality factor, N_s is the number of cells in series, and V_{th} = kT/q is the thermal voltage (with k being Boltzmann’s constant, T the cell temperature in Kelvin, and q the electron charge).

This implementation uses pvlib-python, an open-source library for photovoltaic system modeling. The solution follows the analytical approach described by Jain and Kapoor (2004), which uses the Lambert W function to solve the implicit single diode equation. For more details, see the pvlib i_from_v documentation.

The function supports three numerical methods: lambertw (default, uses the Lambert W analytical solution), newton (Newton-Raphson iterative solver), and brentq (Brent’s method, limited to first quadrant). The nNsVth parameter represents the product of the ideality factor, number of series cells, and thermal voltage, which can be calculated as n \cdot N_s \cdot kT/q.

This example function is provided as-is without any representation of accuracy.

Excel Usage

=I_FROM_V(voltage, photocurrent, saturation_current, resistance_series, resistance_shunt, nNsVth, ifv_method)
  • voltage (float, required): The voltage value
  • photocurrent (float, required): The photocurrent value
  • saturation_current (float, required): The saturation_current value
  • resistance_series (float, required): The resistance_series value
  • resistance_shunt (int, required): The resistance_shunt value
  • nNsVth (float, required): The nNsVth value
  • ifv_method (str, optional, default: “lambertw”): The method value

Returns (float): Device current in Amperes, or error message string.

Examples

Example 1: Demo case 1

Inputs:

voltage photocurrent saturation_current resistance_series resistance_shunt nNsVth ifv_method
0.5 8 1e-10 0.01 1000 1.5 lambertw

Excel formula:

=I_FROM_V(0.5, 8, 1e-10, 0.01, 1000, 1.5, "lambertw")

Expected output:

7.999

Example 2: Demo case 2

Inputs:

voltage photocurrent saturation_current resistance_series resistance_shunt nNsVth ifv_method
0.6 8 1e-10 0.01 1000 1.5 lambertw

Excel formula:

=I_FROM_V(0.6, 8, 1e-10, 0.01, 1000, 1.5, "lambertw")

Expected output:

7.999

Example 3: Demo case 3

Inputs:

voltage photocurrent saturation_current resistance_series resistance_shunt nNsVth ifv_method
0.5 8 1e-10 1 1000 1.5 lambertw

Excel formula:

=I_FROM_V(0.5, 8, 1e-10, 1, 1000, 1.5, "lambertw")

Expected output:

7.992

Example 4: Demo case 4

Inputs:

voltage photocurrent saturation_current resistance_series resistance_shunt nNsVth ifv_method
0.5 8 1e-10 0.01 1000 1.5 newton

Excel formula:

=I_FROM_V(0.5, 8, 1e-10, 0.01, 1000, 1.5, "newton")

Expected output:

7.999

Python Code

import micropip
await micropip.install(["pvlib"])
from pvlib.pvsystem import i_from_v as pvlib_i_from_v

def i_from_v(voltage, photocurrent, saturation_current, resistance_series, resistance_shunt, nNsVth, ifv_method='lambertw'):
    """
    Calculate the device current at a given device voltage for a PV cell/module using the single diode model.

    See: https://pvlib-python.readthedocs.io/en/stable/reference/generated/pvlib.pvsystem.i_from_v.html

    This example function is provided as-is without any representation of accuracy.

    Args:
        voltage (float): The voltage value
        photocurrent (float): The photocurrent value
        saturation_current (float): The saturation_current value
        resistance_series (float): The resistance_series value
        resistance_shunt (int): The resistance_shunt value
        nNsVth (float): The nNsVth value
        ifv_method (str, optional): The method value Valid options: Lambert W, Newton, Brent Q. Default is 'lambertw'.

    Returns:
        float: Device current in Amperes, or error message string.
    """
    try:
        V = float(voltage)
        IL = float(photocurrent)
        I0 = float(saturation_current)
        Rs = float(resistance_series)
        Rsh = float(resistance_shunt)
        nNsVth_ = float(nNsVth)
        if ifv_method not in ["lambertw", "newton", "brentq"]:
            return "Error: Method must be 'lambertw', 'newton', or 'brentq'."
    except Exception:
        return "Error: All arguments must be numbers, except method."
    try:
        result = pvlib_i_from_v(V, IL, I0, Rs, Rsh, nNsVth_, method=ifv_method)
    except Exception as e:
        return f"Error: pvlib.i_from_v - {e}"
    return float(result)

Online Calculator